<template>
  <div ref="myChart" class="radar-echart" />
</template>

<script>
import {getroom} from '@/api/rooms'
const echarts = require('echarts')
export default {
 async mounted() {
   await this.getData()
    // 初始化一个echarts容器
    const myChart = echarts.init(this.$refs.myChart)
    myChart.setOption({
      title: {
        text: '收支详情'
    },
    tooltip: {},
    xAxis: {
        data: [ '住宿收入','维修']
    },
    yAxis: {},
    series: [{
        name: '收支',
        type: 'bar',
        data: this.data
    }]
    })
  },
  data(){
    return{
      roomId:this.$route.params.id,
      data:[]
    }
  },
  methods:{
   async getData(){
    const {time,repair,price}= await getroom(this.roomId)
    let inm=time&&price?time*price:0
    let paym=repair&&repair.expenditure?repair.expenditure:0
    this.data=[inm,paym]
    }
  }
}
</script>

<style>
.radar-echart {
  width: 600px;
  height: 400px;
}
</style>
